<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../public/css/monokai_sublime.min.css">
    <link rel="stylesheet" href="../../public/css/heightlength.css">
    <link rel="stylesheet" href="../../public/css/mxjs.css">
    <link rel="stylesheet" href="../../public/css/prism.css">
    <script src="../../public/js/jquery.js"></script>
    <script src="../../public/js/highlight.min.js"></script>
    <script src="../../public/js/prism.js"></script>
    <script src="../../public/js/clipboard.min.js"></script>

</head>
<body>
<button>点击</button>
<div class="container">
    <div class="jsbg">
        <div class="col-lg-12 mxlength">
            <div class="mx-1">
                <h2>判断对象是否为空</h2>
                <code>
                    tips: 1. object中必须有length属性，返回的数组长度取决于length长度
                    2.key 值必须是数值



                    2.Object.values(object)
                    tips:与第一种不同的是不需要length属性，返回一个对象所有可枚举属性值



                    var arr = [{src:"websrv1"}, {dst:"websrv2"}, {dstport:"80"}];
                    function getproperty(){
                    let newarr=arr.map(function (item,index,arr){
                    return Object.keys(item)[0]
                    });
                    return newarr
                    }
                    console.log(getproperty())

                    3.数组转成对象还说要用遍历得方式或者用fromEntries
                    let arr=[1,3,4];
                    let newarr=Object.entries(arr);

                    console.log( Object.fromEntries(newarr));

                </code>
            </div>
        </div>
        <div class="col-lg-12  ">
      <pre class="mScroll">
        <code class="lang-javascript">
let obj = {
        0: 'nihao',
        1: 'haha',
        2: 'gansha',
        'length': 3
    }
    let arr = Array.from(obj)
    console.log(arr);

            let obj = {
        0: 'nihao',
        1: 'haha',
        2: 'gansha',
    }
    let arr = Object.values(obj)
    console.log(arr);
		</code>
    </pre>
        </div>
    </div>
</div>
<script>
  let arr=[1,3,4];
  let newarr=Object.entries(arr);

  console.log( Object.fromEntries(newarr));
 console.log(arr)


    window.onload = function () {
        var clipboard = new Clipboard('.toolbar-item');
        clipboard.on('success', function (e) {
            console.log(e.text);
        });
        clipboard.on('error', function (e) {
            console.log(e);
        });
        $(".toolbar-item").html("<span>复制</span>")
    }
</script>
</body>
</html>
